drop table if exists t1;
drop procedure if exists p1;
drop procedure if exists p2;
drop procedure if exists p3;
drop procedure if exists p4;
drop function if exists f1;
create table t1 (a int);
begin;
savepoint sv;
create procedure p1() begin end;
rollback to savepoint sv;
begin;
savepoint sv;
alter procedure p1 comment 'changed comment';
rollback to savepoint sv;
begin;
savepoint sv;
drop procedure p1;
rollback to savepoint sv;
begin;
savepoint sv;
create function f1() returns int return 1;
rollback to savepoint sv;
begin;
savepoint sv;
alter function f1 comment 'new comment';
rollback to savepoint sv;
begin;
savepoint sv;
drop function f1;
rollback to savepoint sv;
create procedure p1() begin end;
create function f1() returns int return 1;
lock table t1 write;
create procedure p2() begin end;
alter procedure p1 comment 'changed comment';
drop procedure p1;
create function f2() returns int return 1;
alter function f1 comment 'changed comment';
lock table t1 read;
create procedure p2() begin end;
alter procedure p1 comment 'changed comment';
drop procedure p1;
create function f2() returns int return 1;
alter function f1 comment 'changed comment';
unlock tables;
drop table t1;
create temporary table t1 (a int);
lock table t1 read;
create procedure p2() begin end;
alter procedure p1 comment 'changed comment';
drop procedure p1;
create function f2() returns int return 1;
alter function f1 comment 'changed comment';
unlock tables;
drop function f1;
drop procedure p1;
drop temporary table t1;
create procedure p1() begin end;
create function f1() returns int  begin call p1(); return 1; end;
begin;
select f1();
drop procedure p1;
select f1();
commit;
create procedure p1() begin end;
begin;
select f1();
create procedure p1() begin end;
select f1();
commit;
begin;
select f1();
alter procedure p1 contains sql;
select f1();
commit;
begin;
select f1();
drop function f1;
select f1();
commit;
create function f1() returns int return 1;
begin;
select f1();
create function f1() returns int return 2;
select f1();
commit;
begin;
select f1();
alter function f1 contains sql;
select f1();
commit;
drop function f1;
drop procedure p1;
create function f1() returns int return 1;
create table t1 (a int);
create table t2 (a int, b int);
create trigger t1_ai after insert on t1 for each row insert into t2 (a, b) values (new.a, f1());
begin;
insert into t1 (a) values (1);
drop function f1;
commit;
create function f1() returns int return 1;
create view v1 as select f1() as a;
begin;
select * from v1;
drop function f1;
commit;
